package com.xinchao.service;

import com.xinchao.core.exception.ServiceException;
import com.xinchao.model.DeviceUpgrade;
import com.xinchao.model.User;
import com.xinchao.model.page.PageInfo;
import com.xinchao.model.vo.DeviceUpgradeListVO;
import com.xinchao.model.vo.DeviceUpgradeVO;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.rmi.ServerException;
import java.util.Map;

/**
 * 终端升级Service
 */
public interface UpgradeService {
	
	/**
	 * 保存终端升级
     * @param deviceUpgrade deviceUpgrade对象
     * @param user
     * @param operationIp
     */
	void saveDeviceUpgrade(DeviceUpgrade deviceUpgrade, User user, String operationIp);

	/**
	 * 获取终端升级分页列表
	 * hanqr 2018-08-13
	 * @param upgradeType 升级类型(0:软件；1:固件)
	 * @param pageNum 当前页
	 * @param pageSize 每页条数
	 * @return PageInfo<DeviceUpgradeListVO>
	 */
	PageInfo<DeviceUpgradeListVO> listDeviceUpgradeByPage(Integer upgradeType, Integer pageNum, Integer pageSize);

	/**
	 * 通过ID获取终端升级
	 * @param deviceUpgradeId 终端升级ID
	 * @return DeviceUpgrade
	 * @throws ServerException
	 */
	DeviceUpgrade getDeviceUpgradeById(Long deviceUpgradeId) throws ServerException;

	/**
	 * 更新终端升级
	 * @param deviceUpgrade 终端升级
	 * @param user 当前登录用户
	 * @param operationIp 当前操作ip
	 * @throws ServerException
	 */
	void updateDeviceUpgrade(DeviceUpgrade deviceUpgrade, User user, String operationIp) throws ServerException;

	/**
	 * 根据主键查询固件升级信息
	 * hanqr 2018-08-14
	 * @param deviceUpgradeId 主键
	 * @return DeviceUpgradeVO
	 */
    DeviceUpgradeVO getDeviceUpgradeByIdVo(Long deviceUpgradeId);
    
    /**
	 * 保存apk文件
	 * @param file apk文件
	 * @return
	 * @throws IOException
	 */
	Map<Object, Object> saveApkFile(MultipartFile file) throws IOException;
	
	/**
	 * 保存固件文件名
	 * @param files
	 * @return
	 * @throws IOException
	 */
    Map<Object,Object> saveFirmwareFile(MultipartFile files) throws IOException;

	/**
	 * 升级终端软件版本（仅设置终端升级id）
	 * @param upgradeType     软件升级OR升级固件
	 * @param deviceCodes     终端编码
	 * @param deviceUpgradeId 升级ID
	 * @param user  当前登录用户
	 * @param remortIP        远程IP
	 * @throws ServiceException
	 */
	void deviceUpgrade(Integer upgradeType,String deviceCodes, Long deviceUpgradeId, User user,String remortIP) throws ServiceException;

	/**
	 * 删除升级记录
	 * @param softwareUpgradeId
	 * @param firmwareUpgradeId
	 * @return
	 */
	boolean del(Integer softwareUpgradeId,Integer firmwareUpgradeId);
}
